using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;
using System.Xml;
using System.IO;
using System.Runtime.Remoting;

namespace Xfinity.ContentProcessors
{
    [ContentProcessor(DisplayName="Pluggable content processor")]
    public class PluggableContentProcessor:ModelProcessor
    {
        public override ModelContent Process(Microsoft.Xna.Framework.Content.Pipeline.Graphics.NodeContent input, ContentProcessorContext context)
        {
            PluggableSettings settings = PluggableSettings.Default;
            string filename = settings.DefaultProcessor+".xml";
            XmlReader document = XmlReader.Create(File.Open(filename, FileMode.OpenOrCreate));
            while (document.Read())
            {
                string current = document.ReadElementContentAsString();
                Type t = Type.GetType(current);
                object a = Activator.CreateInstance(t);
                ModelProcessor processor = a as ModelProcessor;
                processor.Process(input, context);
                
            }
            return base.Process(input, context);
        }
    }
}
